﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using Model;

namespace Logic
{
    public class DefaultLogic
    {
        DataAccess.DefaultDataAccess access = new DataAccess.DefaultDataAccess();

        #region 登录校验
        public string Login(string strUserName,string strPassword)
        {
            DataTable dt = access.Login(strUserName, strPassword);
            if (dt==null || dt.Rows.Count<=0)
            {
                return "密码不正确或用户不存在！";
            }
            else if (dt.Rows.Count>1)
            {
                return "账号有问题，存在多个重复账号！";
            }
            else
            {
                return "";
            }
        }
        #endregion

        #region 获取用户信息
        public sUser getUserInfo(string strUserID)
        {
            DataTable dt = access.getUserInfo(strUserID);
            if (dt != null && dt.Rows.Count > 0)
            {
                sUser user = new sUser();
                user.iAutoID = (int)dt.Rows[0]["iAutoID"];
                user.vcUserID = dt.Rows[0]["vcUserID"].ToString();
                user.vcPassword = dt.Rows[0]["vcPassword"].ToString();
                user.vcUserType = dt.Rows[0]["vcUserType"].ToString();
                return user;
            }
            else 
            {
                return null;
            }
        }
        #endregion
    }
}
